home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earcd / phase5 / lha-ppc / src / stat.h < prev    next >
C/C++ Source or Header  |  1997-10-26  |  7KB  |  225 lines

  1. #ifndef _SYS_STAT_INCLUDED
  2. #define _SYS_STAT_INCLUDED
  3.  
  4. /*
  5.  * ** stat structure used by fstat() and stat()
  6.  * ** will not be compatible with your compiler's stat() and fstat()
  7.  */
  8. #include <sys/types.h>
  9.  
  10. #ifndef _BOOL_T
  11. #define _BOOL_T
  12.      typedef int bool_t;
  13. #endif /* _DEV_T */
  14.  
  15. #ifndef _DEV_T
  16. #define _DEV_T
  17.      typedef long dev_t;
  18. #endif /* _DEV_T */
  19.  
  20. #ifndef _ENUM_T
  21. #define _ENUM_T
  22.      typedef int enum_t;        /* For device numbers */
  23. #endif /* _DEV_T */
  24.  
  25. #ifndef _INO_T
  26. #define _INO_T
  27.      typedef unsigned long ino_t;    /* For file serial numbers */
  28. #endif /* _INO_T */
  29.  
  30. #ifndef _MODE_T
  31. #define _MODE_T
  32.      typedef unsigned short mode_t;    /* For file types and modes */
  33. #endif /* _MODE_T */
  34.  
  35. #ifndef _NLINK_T
  36. #define _NLINK_T
  37.      typedef short nlink_t;        /* For link counts */
  38. #endif /* _NLINK_T */
  39.  
  40. #ifndef _OFF_T
  41. #define _OFF_T
  42.      typedef long off_t;        /* For file offsets and sizes */
  43. #endif /* _OFF_T */
  44.  
  45. #ifndef _PID_T
  46. #define _PID_T
  47.      typedef long pid_t;        /* For process and session IDs */
  48. #endif /* _PID_T */
  49.  
  50. #ifndef _GID_T
  51. #define _GID_T
  52.      typedef long gid_t;        /* For group IDs */
  53. #endif /* _GID_T */
  54.  
  55. #ifndef _UID_T
  56. #define _UID_T
  57.      typedef long uid_t;        /* For user IDs */
  58. #endif /* _UID_T */
  59.  
  60. #ifndef _TIME_T
  61. #define _TIME_T
  62.      typedef long time_t;        /* For times in seconds */
  63. #endif /* _TIME_T */
  64.  
  65. #ifndef _SIZE_T
  66. #define _SIZE_T
  67.      typedef unsigned int size_t;    /* Type returned by sizeof() */
  68. #endif /* _SIZE_T */
  69.  
  70. #ifndef _SSIZE_T
  71. #define _SSIZE_T
  72.       typedef int ssize_t;        /* Signed version of size_t */
  73. #endif /* _SSIZE_T */
  74.  
  75. #ifndef _SITE_T
  76. #define _SITE_T
  77.      typedef unsigned short __site_t;    /* see stat.h */
  78. #endif /* _SITE_T */
  79.  
  80. #ifndef _CNODE_T
  81. #define _CNODE_T
  82.      typedef unsigned short __cnode_t;    /* see stat.h */
  83. #endif /* _CNODE_T */
  84.  
  85.    typedef long __daddr_t;        /* For disk block addresses */
  86.    typedef char *__caddr_t;        /* For character addresses */
  87.    typedef long __swblk_t;
  88.  
  89. #ifndef _CADDR_T
  90. #define _CADDR_T
  91.      typedef __caddr_t        caddr_t;   /* also in ptrace.h */
  92. #endif /* _CADDR_T */
  93.  
  94.    typedef unsigned char  ubit8;
  95.    typedef unsigned short ubit16;
  96.    typedef unsigned long  ubit32;
  97.    typedef char       sbit8;
  98.    typedef short      sbit16;
  99.    typedef long       sbit32;
  100.  
  101.    typedef __swblk_t      swblk_t;
  102.    typedef __daddr_t      daddr_t;
  103.    typedef __site_t      site_t;
  104.    typedef __cnode_t      cnode_t;
  105.  
  106.    typedef long       paddr_t;
  107.    typedef short      cnt_t;
  108.    typedef unsigned int   space_t;
  109.    typedef unsigned int   prot_t;
  110.    typedef unsigned long  cdno_t;
  111.    typedef unsigned short use_t;
  112.  
  113.    typedef struct _physadr { int r[1]; } *physadr;
  114.    typedef struct _quad { long val[2]; } quad;
  115.  
  116.    typedef char spu_t;
  117.  
  118. struct stat
  119. {
  120.   dev_t st_dev;
  121.   ino_t st_ino;
  122.   mode_t st_mode;
  123.   nlink_t st_nlink;
  124.   unsigned short st_reserved1;    /* old st_uid, replaced spare positions */
  125.   unsigned short st_reserved2;    /* old st_gid, replaced spare positions */
  126.   dev_t st_rdev;
  127.   off_t st_size;
  128.   time_t st_atime;
  129.   int st_spare1;
  130.   time_t st_mtime;
  131.   int st_spare2;
  132.   time_t st_ctime;
  133.   int st_spare3;
  134.   long st_blksize;
  135.   long st_blocks;
  136.   unsigned int st_pad:30;
  137.   unsigned int st_acl:1;    /* set if there are optional ACL entries */
  138.   unsigned int st_remote:1;    /* Set if file is remote */
  139.   dev_t st_netdev;        /* ID of device containing */
  140.   /* network special file */
  141.   ino_t st_netino;        /* Inode number of network special file */
  142.   __cnode_t st_cnode;
  143.   __cnode_t st_rcnode;
  144.   /* The site where the network device lives                      */
  145.   __site_t st_netsite;
  146.   short st_fstype;
  147.   /* Real device number of device containing the inode for this file */
  148.   dev_t st_realdev;
  149.   /* Steal three spare for the device site number                   */
  150.   unsigned short st_basemode;
  151.   unsigned short st_spareshort;
  152.   uid_t st_uid;
  153.   gid_t st_gid;
  154. #define _SPARE4_SIZE 3
  155.   long st_spare4[_SPARE4_SIZE];
  156. };
  157.  
  158. /* st_mode will have bits set as follows */
  159. /* the least significant 9 bits will be the unix
  160.  * ** rwxrwxrwx bits (octal 777).
  161.  */
  162.  
  163. #ifndef S_IRWXU            /* fcntl.h might have already defined these */
  164. #define S_ISUID 0004000        /* set user ID on execution */
  165. #define S_ISGID 0002000        /* set group ID on execution */
  166.  
  167. #define S_IRWXU 0000700        /* read, write, execute permission (owner) */
  168. #define S_IRUSR 0000400        /* read permission (owner) */
  169. #define S_IWUSR 0000200        /* write permission (owner) */
  170. #define S_IXUSR 0000100        /* execute permission (owner) */
  171.  
  172. #define S_IRWXG 0000070        /* read, write, execute permission (group) */
  173. #define S_IRGRP 0000040        /* read permission (group) */
  174. #define S_IWGRP 0000020        /* write permission (group) */
  175. #define S_IXGRP 0000010        /* execute permission (group) */
  176.  
  177. #define S_IRWXO 0000007        /* read, write, execute permission (other) */
  178. #define S_IROTH 0000004        /* read permission (other) */
  179. #define S_IWOTH 0000002        /* write permission (other) */
  180. #define S_IXOTH 0000001        /* execute permission (other) */
  181. #endif /* S_IRWXU */
  182.  
  183. #define _S_IFMT   0170000    /* type of file */
  184. #define _S_IFREG  0100000    /* regular */
  185. #define _S_IFBLK  0060000    /* block special */
  186. #define _S_IFCHR  0020000    /* character special */
  187. #define _S_IFDIR  0040000    /* directory */
  188. #define _S_IFIFO  0010000    /* pipe or FIFO */
  189. #define S_IFMT      _S_IFMT    /* type of file */
  190. #define S_IFBLK   _S_IFBLK    /* block special */
  191. #define S_IFCHR   _S_IFCHR    /* character special */
  192. #define S_IFDIR   _S_IFDIR    /* directory */
  193. #define S_IFIFO   _S_IFIFO    /* pipe or FIFO */
  194. #define S_IFREG   _S_IFREG    /* regular */
  195.  
  196. #define S_IFSOCK  0140000    /* socket */
  197. #define S_IFLNK   0120000    /* symbolic link */
  198. #define S_IFNWK   0110000    /* network special */
  199.  
  200. #define S_ISDIR(_M)  ((_M & _S_IFMT)==_S_IFDIR)        /* test for directory */
  201. #define S_ISCHR(_M)  ((_M & _S_IFMT)==_S_IFCHR)        /* test for char special */
  202. #define S_ISBLK(_M)  ((_M & _S_IFMT)==_S_IFBLK)        /* test for block special */
  203. #define S_ISREG(_M)  ((_M & _S_IFMT)==_S_IFREG)        /* test for regular file */
  204. #define S_ISFIFO(_M) ((_M & _S_IFMT)==_S_IFIFO)        /* test for pipe or FIFO */
  205. #define S_ISSOCK(_M) ((_M & S_IFMT)==S_IFSOCK)    /* test for socket */
  206. #define S_ISLNK(_M)  ((_M & S_IFMT)==S_IFLNK)    /* test for symbolic link */
  207.  
  208. int stat(const char *name, struct stat *buf);
  209. int lstat(const char *name, struct stat *buf);
  210. int fstat(int fd, struct stat *buf);
  211.  
  212. #ifndef S_IREAD
  213. #define S_IREAD      S_IRUSR
  214. #define S_IWRITE     S_IWUSR
  215. #define S_IEXEC      S_IXUSR
  216. #endif
  217.  
  218. #define btod(p, t) ((t)(((long)p)<<2))
  219. #define dtob(p) ((BPTR)((long)(p)>>2))
  220.  
  221. #define EBADF        9    /* bad file handle            */
  222. #define ENOMEM        12    /* no memory                */
  223.  
  224. #endif /* _SYS_STAT_INCLUDED */
  225.